<% if try_spree_current_user.present? %>
  <div class="user-dropdown" id="user-menu">
    <%= dropdown do %>
      <%= dropdown_toggle class: 'user-dropdown-button dropdown-toggle' do %>
        <%= render_avatar(try_spree_current_user, width: 32, height: 32) %>
        <span class="user-name d-none d-lg-block">
          <% if try_spree_current_user.name.present? %>
            <%= try_spree_current_user.name&.full %>
          <% else %>
            <%= try_spree_current_user.email %>
          <% end %>
        </span>
      <% end %>
      <%= dropdown_menu class: 'ml-2', style: 'min-width: 250px;' do %>
        <div class="d-flex align-items-center p-2 bg-light rounded-lg">
          <%= render_avatar(try_spree_current_user, width: 34, height: 34) %>
          <span class="d-flex flex-column ml-2">
            <% if try_spree_current_user.name.present? %>
              <%= try_spree_current_user.name&.full %>
              <small class="text-muted"><%= try_spree_current_user.email %></small>
            <% else %>
              <%= try_spree_current_user.email %>
            <% end %>
          </span>
        </div>

      <%= render_admin_partials(:user_dropdown_partials) %>

      <% if can?(:update, try_spree_current_user) %>
        <h6 class="dropdown-header mt-2">
          <%= Spree.t(:account) %>
        </h6>
        <%= link_to_with_icon 'user-scan', Spree.t('admin.edit_profile'), spree.edit_admin_profile_path, class: 'dropdown-item' %>
      <% end %>

      <% if can?(:manage, current_store) %>
        <h6 class="dropdown-header mt-2">
          <%= Spree.t(:support) %>
        </h6>
        <%= link_to_with_icon 'book',  Spree.t('admin.documentation'), 'https://spreecommerce.org/docs', class: 'dropdown-item', target: '_blank' %>
        <%= link_to_with_icon 'brand-slack', Spree.t('admin.slack'), 'https://slack.spreecommerce.org/', class: 'dropdown-item', target: '_blank' %>
        <%= link_to_with_icon 'message', Spree.t(:contact_us), 'https://spreecommerce.org/contact/', class: 'dropdown-item', target: '_blank' %>
      <% end %>

      <div class="dropdown-divider"></div>

        <%= button_to spree_admin_logout_path, class: 'dropdown-item mb-0 btn-danger', method: :delete do %>
          <%= icon('logout', class: "icon icon-logout")  %>
          <%= Spree.t(:logout) %>
        <% end if defined?(spree_admin_logout_path) %>
      <% end %>
    <% end %>
  </div>
<% end %>
